﻿function writeLog(sendingContent, logtype, sendStatus, operator, categoryid) {
 
    var textToWrite = logtype + "Sent";
    var currentDate = new Date();

    var LogDate = currentDate.getDate() + "-" + (currentDate.getMonth() + 1) + "-" + currentDate.getFullYear();

    var currentTime = new Date()
    var LogTime = currentTime.getHours() + ':' + currentTime.getMinutes() + ':' + currentTime.getSeconds();

    textToWrite += ", " + LogDate + " " + LogTime;

    textToWrite += ", Sending Status: " + sendStatus;
   
    textToWrite += ", Template CategoryID: " + categoryid;
     
    if (getQuerystring('contact_id', 0) == 0)
        textToWrite += ", AppID:" + getQuerystring("app_id", '');
    else if (getQuerystring("app_id", '') == 0)
        textToWrite += ", ContactID:" + getQuerystring("contact_id", '');

    textToWrite += ", Operator:" + operator;

    if (sendingContent.length > 100)
        sendingContent = sendingContent.substring(0, 100);

    textToWrite += ", Sent Content :" + sendingContent;

    $.ajax({
        url: "/WebServices/SMSHandler.ashx?method=WriteLogForSMSEmail",
        data: { logText: textToWrite },
        success: function (result) {
            if (result == "0")
                $.messager.alert('Morgan CRM', 'Error while writing Log File');
        }
    });
}